package com.pospi.xstore.ui.login_ui;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.view.WindowManager;

import com.lany.sp.SPHelper;
import com.pospi.xstore.R;
import com.pospi.xstore.ui.MainActivity;
import com.pospi.xstore.ui.base.BaseActivity;

public class SplashActivity extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        // 闪屏的核心代码
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                boolean isIn = SPHelper.getInstance().getBoolean("isLogin");
                if (!isIn) {
                    startActivity(LoginActivity.class);
                } else {
                    startActivity(MainActivity.class);
                }

                SplashActivity.this.finish(); // 结束启动动画界面
            }
        }, 1500); //启动动画持续1.5秒钟
    }
}
